package com.ssm.order.controller;

import com.ssm.dto.CommonResult;
import com.ssm.model.order.OrderModel;
import com.ssm.model.stock.StockModel;
import com.ssm.order.fegin.StockFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OpenFeginDemoController {

    @Autowired
    private StockFeign stockFeign;


    @GetMapping("/hello1")
    public CommonResult<OrderModel> hello() {
        CommonResult<StockModel> result = stockFeign.getStockDetail();
        if (result.getCode() != 1) {
            return CommonResult.error(null, result.getCode(), result.getMessage());
        }
        StockModel stockDetail = result.getData();
        OrderModel orderModel = new OrderModel();
        orderModel.setStockModel(stockDetail);
        return CommonResult.success(orderModel);
    }
}
